package com.lujieni.springbootjasypt.controller;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：小鹿爱吃鱼
 * @Date: 2025/6/3 17:45
 * @Description:
 */
@RestController
public class HelloController {

    @Value("${content}")
    private String content;

    @Value("${age}")
    private String age;

    @GetMapping("/hello")
    public String hello(){
        return content+"-"+age;
    }


    public static void main(String[] args) {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        // 指定加密算法，和配置文件中一致
        config.setAlgorithm("PBEWithMD5AndDES");
        // 指定加密秘钥，此处使用"cmclink"字符串
        config.setPassword("cmclink");
        encryptor.setConfig(config);

        // 待加密的明文数据（此处100.104.226.11:8848为nacos登录url）
        String plainText = "helloworld";
        // 生成密文数据
        String encryptText = encryptor.encrypt(plainText);
        System.out.println(encryptText);
    }



}
